import Relay from 'react-relay';

export default class AddContractMutation extends Relay.Mutation {
  static fragments = {};

  getConfigs() {
    return [{
      type: 'RANGE_ADD',
      parentName: 'company',
      parentID: this.props.payload.company_id,
      connectionName: 'contracts',
      edgeName: 'contractEdge',
      rangeBehaviors: () => 'prepend',
    }];
  }

  getMutation = () => Relay.QL`mutation { addContract }`;

  getVariables() {
    return { ...this.props.payload };
  }

  getFatQuery = () => (
    Relay.QL`
      fragment on addContractPayload {
        company{
          contracts
        }
        contractEdge
      }
    `
  )
}
